﻿@model DevFramework.Business.Concrete.Managers.CartManager

@{
    ViewBag.Title = @Word("Main.Cart.CartDetails.Title");
    Layout = "../_Layout.cshtml";
    var sepetim = Model.List();
}

<h4 class="page-header">@Word("Main.Cart.CartDetails.Title")</h4>

<div class="table-responsive">
    <table class="table table-hover">
        <thead>
            <tr class="bold">
                <th>@Word("Main.Product.ProductName")</th>
                <th>@Word("Main.Product.UnitPrice")</th>
                <th>@Word("Main.Product.Units")</th>
                <th>@Word("Main.Product.Total")</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var cartLine in sepetim)
            {
                <tr>
                    <td>@cartLine.Product.ProductName</td>
                    <td>@cartLine.Product.UnitPrice</td>
                    <td>@cartLine.Quantity</td>
                    <td>@((cartLine.Quantity * cartLine.Product.UnitPrice).ToString("c"))</td>
                    <td>

                        @using (Ajax.BeginForm("RemoveFromCart", "Cart", new AjaxOptions() { UpdateTargetId = "cart", OnSuccess = "onSuccess(this)" }))
                        {
                            @Html.Hidden("productId", cartLine.Product.ProductId)
                            <input type="submit" class="btn btn-xs btn-danger" value=@Word("Main.Cart.RemoveFromCart") />
                        }

                    </td>
                </tr>
            }
        </tbody>
        <tfoot>
            <tr>
                <td colspan="5">
                    @Html.ActionLink(@Word("Main.Order.CompleteShopping").ToString(), "Checkout", new { controller = "Cart" }, new { @class = "btn btn-xs btn-primary pull-right" })
                </td>
            </tr>
        </tfoot>
    </table>
</div>

@section Scripts
{
    <script type="text/javascript">
        var onSuccess = function (row) {
            $(row).parent('td').parent('tr').remove();
        }
    </script>
}
